#!/bin/bash
while(true)
do
    # get_product
    while(true)
    do  
        cd /home/www/itaobao/Script
        scriptName="php /home/www/itaobao/Script/get_product.php"
        psCount=`ps aux | grep -v grep | grep "$scriptName" | wc -l`
        echo "get_product $psCount"
        if [ $psCount -lt 1 ] ; then
            nohup php /home/www/itaobao/Script/get_product.php  &> /dev/null &
            sleep 1
        else
            break
        fi
    done

    # get_coupon_product
    while(true)
    do  
        cd /home/www/itaobao/Script
        scriptName="php /home/www/itaobao/Script/get_coupon_product.php"
        psCount=`ps aux | grep -v grep | grep "$scriptName" | wc -l`
        echo "get_coupon_product $psCount"
        if [ $psCount -lt 1 ] ; then
            nohup php /home/www/itaobao/Script/get_coupon_product.php  &> /dev/null &
            sleep 1
        else
            break
        fi
    done

    # get_tui_product
    while(true)
    do  
        cd /home/www/itaobao/Script
        scriptName="php /home/www/itaobao/Script/get_tui_product.php"
        psCount=`ps aux | grep -v grep | grep "$scriptName" | wc -l`
        echo "get_tui_product $psCount"
        if [ $psCount -lt 1 ] ; then
            nohup php /home/www/itaobao/Script/get_tui_product.php  &> /dev/null &
            sleep 1
        else
            break
        fi
    done

    # clean_data
    while(true)
    do  
        cd /home/www/itaobao/Script
        scriptName="php /home/www/itaobao/Script/clean_data.php"
        psCount=`ps aux | grep -v grep | grep "$scriptName" | wc -l`
        echo "clean_data $psCount"
        if [ $psCount -lt 1 ] ; then
            nohup php /home/www/itaobao/Script/clean_data.php  &> /dev/null &
            sleep 1
        else
            break
        fi
    done

    sleep 60
done